package com.ruoyi.web.controller.statistics;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.statistics.domain.StatisticsQuestion;
import com.ruoyi.statistics.service.IStatisticsQuestionService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 用户问题建议 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-11-11
 */
@Controller
@RequestMapping("/statistics/statisticsQuestion")
public class StatisticsQuestionController extends BaseController
{
    private String prefix = "statistics/statisticsQuestion";
	
	@Autowired
	private IStatisticsQuestionService statisticsQuestionService;
	
	@RequiresPermissions("statistics:statisticsQuestion:view")
	@GetMapping()
	public String statisticsQuestion()
	{
	    return prefix + "/statisticsQuestion";
	}
	
	/**
	 * 查询用户问题建议列表
	 */
	@RequiresPermissions("statistics:statisticsQuestion:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(StatisticsQuestion statisticsQuestion)
	{
		startPage();
        List<StatisticsQuestion> list = statisticsQuestionService.selectStatisticsQuestionList(statisticsQuestion);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出用户问题建议列表
	 */
	@RequiresPermissions("statistics:statisticsQuestion:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(StatisticsQuestion statisticsQuestion)
    {
    	List<StatisticsQuestion> list = statisticsQuestionService.selectStatisticsQuestionList(statisticsQuestion);
        ExcelUtil<StatisticsQuestion> util = new ExcelUtil<StatisticsQuestion>(StatisticsQuestion.class);
        return util.exportExcel(list, "statisticsQuestion");
    }
	
	/**
	 * 新增用户问题建议
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存用户问题建议
	 */
	@RequiresPermissions("statistics:statisticsQuestion:add")
	@Log(title = "用户问题建议", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(StatisticsQuestion statisticsQuestion)
	{		
		return toAjax(statisticsQuestionService.insertStatisticsQuestion(statisticsQuestion));
	}

	/**
	 * 修改用户问题建议
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		StatisticsQuestion statisticsQuestion = statisticsQuestionService.selectStatisticsQuestionById(id);
		mmap.put("statisticsQuestion", statisticsQuestion);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存用户问题建议
	 */
	@RequiresPermissions("statistics:statisticsQuestion:edit")
	@Log(title = "用户问题建议", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(StatisticsQuestion statisticsQuestion)
	{		
		return toAjax(statisticsQuestionService.updateStatisticsQuestion(statisticsQuestion));
	}
	
	/**
	 * 删除用户问题建议
	 */
	@RequiresPermissions("statistics:statisticsQuestion:remove")
	@Log(title = "用户问题建议", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(statisticsQuestionService.deleteStatisticsQuestionByIds(ids));
	}
	
}
